
********************************************************************************
********************************************************************************
*****																	   *****
***** Replication code for 
***** "Loyal Lists, Distinctive Districts: How Dissent-Shirking and        *****
***** Leisure-Shirking Affects Mixed-Candidate Selection" (WEP, 2022)	   *****
***** Authors: Lukas Hohendorf & David Schmuck  						   *****
***** 																	   *****
***** https://doi.org/10.1080/01402382.2022.2137310         			   *****
***** 																	   *****
********************************************************************************
********************************************************************************


**# PRE-SETTINGS
clear all
version 18.0

* Set working directory 
cd "~\Schmuck Hohendorf WEP replication\"

* Load data
use "Schmuck_Hohendorf_WEP_replication_data.dta"

* Set scheme for graphs
set scheme s1mono
graph set window fontface "UB Scala"

* Glance at data
codebook

**# CREATE SAMPLE
* Note: Dataset contains all Members of German Bundestag (MP)
* For our sample, we only need MPs who re-run either as candidate on party list or in single-member district
drop if listpos_change_absolut==. & smd_fail==.
* Note: For MPs who run for the same party but in a different region/on different party list have missing coded in listpos_change_absolut are also dropped

* Drop MPs who participated in less than 50 RCVs
drop if allwoewof1yb<=50

* Drop MPs who have standardised voting agreement values below three standard deviations from the PPG mean
drop if pezrcvloyrate_bothwof1yb<=-3


**# TABLE A.1: Summary statistics
estpost summarize ///
pezrcvloyrate_bothwof1yb ///
peznumb_speech_1000words_1yb_py ///
pezatturate1ybwof ///
pezcombquestions1yb_py ///
pezcombanfr1yb_py ///
reg prop_leaver_list_med relativ_listposlvv govoff partyoff dualcand mandate terms gender age10 east SPD CDU CSU FDP Greens Left ElectoralPeriod12 ElectoralPeriod13 ElectoralPeriod14 ElectoralPeriod15 ElectoralPeriod16 ElectoralPeriod17 ElectoralPeriod18 ///
if listpos_worselvv!=. & pezrcvloyrate_bothwof1yb!=. & peznumb_speech_1000words_1yb_py!=. & ///
pezatturate1ybwof!=. & pezcombquestions1yb_py!=. & pezcombanfr1yb_py!=. & ///
reg!=. & prop_leaver_list!=. & relativ_listposlvv!=. & govoff!=. & partyoff!=. & ///
dualcand!=. & mandate!=. & terms!=. & gender!=. & age10!=. & east!=. & ///
party_elec!=. & elecper!=. & listpos_fail!=. 

esttab ., ///
cells("mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))") ///
label ///
nonumber ///
title("Summary Statistics") ///
collabels("Mean" "SD" "Min" "Max")


**# FIGURE 1: Average marginal effects on P(PR-Tier Nomination Failure) and P(ListPosition Change)

* Run Model 1
logit listpos_fail c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper, cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA2_replication.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC', Pseudo R squared, e(r2_p))

margins,dydx(*) post
estimates store Fail

* Run Model 2
logit listpos_worselvv c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper, cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA2_replication.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC', Pseudo R squared, e(r2_p))

margins,dydx(*) post
estimates store Worse

* Run Model 3
logit listpos_betterlvv c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if nobetterpossible!=1, cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA2_replication.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC', Pseudo R squared, e(r2_p))

margins,dydx(*) post
estimates store Better

* Create figure
coefplot (Fail, label("PR nomination failure")) (Worse) (Better), byopts(row(1)) drop(_cons 1.reg prop_leaver_list_med relativ_listposlvv age10 1.govoff 1.gender 1.dualcand terms 1.mandate 1.partyoff 1.east 13.elecper 14.elecper 15.elecper 16.elecper 17.elecper 18.elecper 2.party_elec 3.party_elec 4.party_elec 5.party_elec 6.party_elec) xline(0) levels(95 90) ciopts(recast(. rcap)) xtitle(Average Marginal Effect) xlab(-.05(.01).05) legend(rows(1) position(6)) xsize(7) title("Average Marginal Effects on P(List Position Change)") ///
coeflabels(pezrcvloyrate_bothwof1yb = "RCV loyalty rate" ///
               pezatturate1ybwof = "RCV attendance rate" ///
               pezcombanfr1yb_py = "Mean number of parl. interp." ///
               pezcombquestions1yb_py = "Mean number of parl. quest." ///
			   peznumb_speech_1000words_1yb_py = "Mean number of parl. speeches" 1.reg = "Government MP") ///
               grid(glcolor (black%30) glpattern(solid))
graph export "Schmuck_Hohendorf_Fig1_coefplot_margins_reduced.png", as(png) width(2000) replace
graph export "Schmuck_Hohendorf_Fig1_margins_reduced.tif", as(tif) replace



**# FIGURE 2: Average marginal effects on P(Nomination Failure)
* Re-Run Model 1
logit listpos_fail c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if allwoewof1yb>50 & pezrcvloyrate_bothwof1yb>-3, cluster(mp_id)
estat ic

margins,dydx(*) post
estimates store mmdfail

* Run Model 4
logit smd_fail c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg i.govoff i.partyoff i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if listonly!=1, cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA2_replication.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC', Pseudo R squared, e(r2_p))

margins,dydx(*) post
estimates store smdfail 

* Create figure
coefplot (mmdfail, label("PR nomination failure")) (smdfail, label("FPTP nomination failure") msymbol(Th)),  byopts(row(1)) drop(_cons 1.reg prop_leaver_list_med relativ_listposlvv age10 1.govoff 1.gender 1.dualcand terms 1.mandate 1.partyoff 1.east 13.elecper 14.elecper 15.elecper 16.elecper 17.elecper 18.elecper 2.party_elec 3.party_elec 4.party_elec 5.party_elec 6.party_elec) xline(0) levels(95 90) ciopts(recast(. rcap)) xtitle(Average Marginal Effect) xlab(-.05(.01).05) legend(rows(1) position(6)) xsize(7) title("Average Marginal Effects on P(Nomination Failure)") ///
coeflabels(pezrcvloyrate_bothwof1yb = "RCV loyalty rate" ///
               pezatturate1ybwof = "RCV attendance rate" ///
               pezcombanfr1yb_py = "Mean number of parl. interp." ///
               pezcombquestions1yb_py = "Mean number of parl. quest." ///
			   peznumb_speech_1000words_1yb_py = "Mean number of parl. speeches" 1.reg = "Government MP") ///
               grid(glcolor (black%30) glpattern(solid))
graph export "Schmuck_Hohendorf_Fig2_margins_reduced.png", as(png) width(2000) replace
graph export "Schmuck_Hohendorf_Fig2_margins_reduced.tif", as(tif) replace


**# TABLE 1: Nomination failures and changes in list position by PPG, 1990–2017
tab smd_fail party_elec if _est_smdfail==1, col //SMD nomination failures for CDU+CSU (= 39) divided by 888 + 105 (=993)
tab listpos_fail party_elec if _est_mmdfail==1, col //MMD nominiation failures for CDU+CSU (=31) divided by 904 + 141 (=1045)
tab listpos_change_absolut party_elec if _est_Worse==1, col


**# TABLE A.3.1: Robustness check: Change in list position relative to list length as dependent variable (Baumann et al. 2017)

logit listpos_worse_bdk c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if relativ_listposlvv!=. & listpos_change_absolut!=. , cluster(mp_id)
outreg2 using "Schmuck_Hohendorf_WEP_TableA3-1_replication.doc", drop(i.elecper) dec(3)  addstat (Pseudo R squared, e(r2_p))

logit listpos_better_bdk c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if nobetterpossible!=1 & relativ_listposlvv!=. & listpos_change_absolut!=., cluster(mp_id)
outreg2 using "Schmuck_Hohendorf_WEP_TableA3-1_replication.doc", drop(i.elecper) dec(3)  addstat (Pseudo R squared, e(r2_p))


**# TABLE A.3.2: Robustness check: Relative list position as dependent variable (Louwerse and van Vonno 2021)
reg relativ_listpos_nextlvv c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py i.reg c.pezcombanfr1yb_py c.prop_leaver_list c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if listpos_change_absolut!=.,cluster(mp_id)
outreg2 using "Schmuck_Hohendorf_WEP_TableA3-2_replication.doc", drop(i.elecper) dec(3)


**# TABLE A.3.3: Robustness check with panel models

* Setting panel data
xtset mp_id elecper

/*
* Re-run Model 1 (without panel)
logit listpos_fail c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper, cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "panelrobustlipofail.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC')
*/

* Run Model 8
xtlogit listpos_fail c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper, re
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA3-3_replication.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC')

/*
* Run Model 9 (with clustered standard errors; not shown in appendix)
logit listpos_worselvv c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper,cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "panelrobustworse.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC')
*/

* Run Model 9
xtlogit listpos_worselvv c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper,re
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA3-3_replication.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC')

/*
* Run Model 10 (with clustered standard errors; not shown in appendix)
logit listpos_betterlvv c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if nobetterpossible!=1,cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "panelrobustbetter.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC')
*/

* Run Model 10
xtlogit listpos_betterlvv c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg c.prop_leaver_list_med c.relativ_listposlvv  i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if nobetterpossible!=1,re
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA3-3_replication.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC')

/*
* Run Model 11 (with clustered standard errors; not shown in appendix)
logit smd_fail c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg i.govoff i.partyoff i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if listonly!=1, cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "panelrobustsmdfail.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC')
*/

* Run Model 11
xtlogit smd_fail c.pezrcvloyrate_bothwof1yb c.peznumb_speech_1000words_1yb_py c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg i.govoff i.partyoff i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if listonly!=1,re
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA3-3_replication.doc", drop(i.elecper) dec(3) addstat(AIC, `AIC', BIC, `BIC')


**# TABLE A.4: Regression table for models 5-6 (speech models)

* Run Model 12
reg c.peznumb_speech_1000words_1yb_py c.pezrcvloyrate_bothwof1yb c.pezatturate1ybwof c.pezcombquestions1yb_py c.pezcombanfr1yb_py i.reg i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if elecper!=19, cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA4_replication.doc", drop(i.elecper) dec(3)

* Run Model 13
reg c.peznumb_speech_1000words_1yb_py c.pezrcvloyrate_bothwof1yb i.reg i.govoff i.partyoff i.dualcand i.mandate c.terms i.gender c.age10 i.east i.party_elec i.elecper if pezatturate1ybwof!=. & pezcombquestions1yb_py!=. & pezcombanfr1yb_py!=. & elecper!=19, cluster(mp_id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Schmuck_Hohendorf_WEP_TableA4_replication.doc", drop(i.elecper) dec(3)


**# TABLE A.5: Mediation analysis result

foreach i of num 12/18 {
g lp`i'=0
replace lp`i'=1 if elecper==`i'
}

foreach i of num 1/6 {
g party`i'=0
replace party`i'=1 if party_elec==`i'
}

medeff (regress peznumb_speech_1000words_1yb_py pezrcvloyrate_bothwof1yb reg govoff partyoff dualcand mandate terms gender age10 east party2 party3 party4 party5 party6 lp13 lp14 lp15 lp16 lp17 lp18) (logit listpos_fail pezrcvloyrate_bothwof1yb peznumb_speech_1000words_1yb_py reg prop_leaver_list relativ_listposlvv  govoff partyoff dualcand mandate terms gender age10 east party2 party3 party4 party5 party6 lp13 lp14 lp15 lp16 lp17 lp18) if listpos_worselvv!=. & pezrcvloyrate_bothwof1yb!=. & peznumb_speech_1000words_1yb_py!=. & pezatturate1ybwof!=. & pezcombquestions1yb_py!=. & pezcombanfr1yb_py!=. & listpos_change_absolut!=. , mediate(peznumb_speech_1000words_1yb_py) treat(pezrcvloyrate_bothwof1yb) sims(2000)

medeff (regress peznumb_speech_1000words_1yb_py pezrcvloyrate_bothwof1yb reg govoff partyoff dualcand mandate terms gender age10 east party2 party3 party4 party5 party6 lp13 lp14 lp15 lp16 lp17 lp18) (logit listpos_worselvv pezrcvloyrate_bothwof1yb peznumb_speech_1000words_1yb_py reg prop_leaver_list relativ_listposlvv  govoff partyoff dualcand mandate terms gender age10 east party2 party3 party4 party5 party6 lp13 lp14 lp15 lp16 lp17 lp18) if listpos_worselvv!=. & pezrcvloyrate_bothwof1yb!=. & peznumb_speech_1000words_1yb_py!=. & pezatturate1ybwof!=. & pezcombquestions1yb_py!=. & pezcombanfr1yb_py!=. & listpos_change_absolut!=. , mediate(peznumb_speech_1000words_1yb_py) treat(pezrcvloyrate_bothwof1yb) sims(2000)

medeff (regress peznumb_speech_1000words_1yb_py pezrcvloyrate_bothwof1yb reg govoff partyoff dualcand mandate terms gender age10 east party2 party3 party4 party5 party6 lp13 lp14 lp15 lp16 lp17 lp18) (logit listpos_betterlvv pezrcvloyrate_bothwof1yb peznumb_speech_1000words_1yb_py reg prop_leaver_list relativ_listposlvv  govoff partyoff dualcand mandate terms gender age10 east party2 party3 party4 party5 party6 lp13 lp14 lp15 lp16 lp17 lp18) if listpos_worselvv!=. & pezrcvloyrate_bothwof1yb!=. & peznumb_speech_1000words_1yb_py!=. & pezatturate1ybwof!=. & pezcombquestions1yb_py!=. & pezcombanfr1yb_py!=. & listpos_change_absolut!=. & nobetterpossible!=1 , mediate(peznumb_speech_1000words_1yb_py) treat(pezrcvloyrate_bothwof1yb) sims(2000)

